﻿<!DOCTYPE HTML>
<html lang="zh">
<head>
<title>CoordMode - 语法 &amp; 使用 | AutoHotkey v2</title>
<meta name="description" content="The CoordMode function sets coordinate mode for various built-in functions to be relative to either the active window or the screen." />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="../static/theme.css" rel="stylesheet" type="text/css" />
<script src="../static/content.js" type="text/javascript"></script>
<script type="text/javascript">$(function(){0<=window.navigator.userAgent.toLowerCase().indexOf("ucbrowser")&&CaoNiMaDeUc()})</script>
</head>
<body>

<h1>CoordMode</h1>

<p>Sets coordinate mode for various built-in functions to be relative to either the active window or the screen.</p>

<pre class="Syntax"><span class="func">CoordMode</span> TargetType <span class="optional">, RelativeTo</span></pre>
<h2 id="Parameters">参数</h2>
<dl>

  <dt>TargetType</dt>
  <dd>
    <p>类型: <a href="../Concepts.htm#strings">字符串</a></p>
    <p>The type of target to affect. Specify one of the following words:</p>
    <p><strong>ToolTip</strong>: Affects <a href="ToolTip.htm">ToolTip</a>.</p>
    <p><strong>Pixel</strong>: Affects <a href="PixelGetColor.htm">PixelGetColor</a>, <a href="PixelSearch.htm">PixelSearch</a>, and <a href="ImageSearch.htm">ImageSearch</a>.</p>
    <p><strong>Mouse</strong>: Affects <a href="MouseGetPos.htm">MouseGetPos</a>, <a href="Click.htm">Click</a>, and <a href="MouseMove.htm">MouseMove</a>/<a href="MouseClick.htm">Click</a>/<a href="MouseClickDrag.htm">Drag</a>.</p>
    <p><strong>Caret</strong>: Affects <a href="CaretGetPos.htm">CaretGetPos</a>.</p>
    <p><strong>Menu</strong>: Affects the <a href="../objects/Menu.htm#Show">Menu.Show</a> method when coordinates are specified for it.</p>
  </dd>

  <dt>RelativeTo</dt>
  <dd>
      <p>类型: <a href="../Concepts.htm#strings">字符串</a></p>
      <p>The area to which <em>TargetType</em> is to be related. Specify one of the following words (if omitted, it defaults to Screen):</p>
      <p><strong>Screen</strong>: Coordinates are relative to the desktop (entire screen).</p>
      <p><strong>Relative</strong>: Coordinates are relative to the active window.</p>
      <p><strong>Window</strong>: Synonymous with <em>Relative</em> and recommended for clarity.</p>
      <p id="Client"><strong>Client</strong>: Coordinates are relative to the active window's client area, which excludes the window's title bar, menu (if it has a standard one) and borders.  Client coordinates are less dependent on OS version and theme.</p>
  </dd>

</dl>

<h2 id="Remarks">备注</h2>
<p>If this function is not used, all built-in functions except those documented otherwise (e.g. <a href="WinMove.htm">WinMove</a> and <a href="InputBox.htm">InputBox</a>) use coordinates that are relative to the active window's client area.</p>
<p>每个新运行的<a href="../misc/Threads.htm">线程</a>(如 <a href="../Hotkeys.htm">热键</a>, <a href="../objects/Menu.htm">自定义菜单项</a>或<a href="SetTimer.htm">定时</a>子程序) 都会以此函数的默认设置开始. 这个默认设置可以通过在脚本的自动执行段(脚本的顶部) 使用此函数来改变.</p>
<p>The built-in <a href="../Variables.htm#CoordMode">A_CoordMode variables</a> contain the current settings.</p>
<h2 id="Related">相关</h2>
<p><a href="Click.htm">Click</a>, <a href="MouseMove.htm">MouseMove</a>, <a href="MouseClick.htm">MouseClick</a>, <a href="MouseClickDrag.htm">MouseClickDrag</a>, <a href="MouseGetPos.htm">MouseGetPos</a>, <a href="PixelGetColor.htm">PixelGetColor</a>, <a href="PixelSearch.htm">PixelSearch</a>, <a href="ToolTip.htm">ToolTip</a>, <a href="../objects/Menu.htm">Menu.Show</a></p>
<h2 id="Examples">示例</h2>
<div class="ex" id="ExBasic">
<p><a href="#ExBasic">#1</a></p>
<pre>CoordMode "ToolTip", "Screen"  <em>; 把 ToolTips 放置在相对于屏幕坐标的位置.</em>
CoordMode "ToolTip"  <em>; 和上面效果相同, 因为 &quot;screen&quot; 是默认的坐标模式.</em></pre>
</div>

</body>
</html>